#include <init/GDT.h>
#include <init/IDT.h>
#include <init/ISR.h>
#include <init/IRQ.h>
#include <init/PIT.h>

#include <video/VGA.h>

#include <types.h>
#include <string.h>

void hardware_init()
{
    gdt_install();
    idt_install();
    isr_install();
    irq_install();
    timer_install();

    init_video();

    /* Turn on the interrupts */
    __asm__ __volatile__ ("sti");
}

int main(multiboot_info_t* mbi, unsigned int magic)
{
    _u32 conventional_mem;
    _u32 extended_mem;

    hardware_init();

//    multiboot_memory_map_t* mmap = mbi->mmap_addr;

//    while(mmap < mbi->mmap_addr + mbi->mmap_length) 
//    {
//      mmap = (multiboot_memory_map_t*) ((unsigned int)mmap + mmap->size + sizeof(unsigned int));
//    }

    if(mbi->flags^1)
    {
	conventional_mem = mbi->mem_lower;
	extended_mem 	 = mbi->mem_upper;

        printk("Lower mem: %d\n KBytes", conventional_mem);
        printk("Upper mem: %d\n KBytes", extended_mem);
    }
  else
    {
	printk("WARNING: Couldn't detect memory!\n");
    }


//    int a = 10/0;
//    putc(a);

    for (;;);

    return 0;
}

